.netCHARTING v10.5 Documentation


dotnetCHARTING Namespace > FinancialEngine Class > WeightedMovingAverage Method : WeightedMovingAverage(String,Series,ElementValue,Double[]) Method
The name of the series which will be displayed on the chart, i.e. its label.
An series of historical values, where the first element corresponds to the market on the last period, the second term to the value on previous period and so on.
Specifies the particular element value (for example High, Low, Close or Open of the financial time series) which will be considered within this indicator evaluation. In particular, if you wish to use the element value high then you should pass the parameter High. In a similarly fashion if you wish to use the low, close or open, then you should pass the parameter Low, Close, Open, respectively.
Array of doubles which assigns weights to the k-th previous historical values for the given period on which the moving average is being evaluated. Here k is just the length of the weights array given.
WeightedMovingAverage(String,Series,ElementValue,Double[]) Method
Here we evaluate the Weighted Moving Average(WMA) where for each period for which the WMA is evaluated the historical terms are weighted in accordance with the same set of weights.
Syntax
'Declaration
 
Public Overloads Shared Function WeightedMovingAverage( _
   ByVal seriesName As String, _
   ByVal s As Series, _
   ByVal elementValue As ElementValue, _
   ByVal weights() As Double _
) As Series
'Usage
 
Dim seriesName As String
Dim s As Series
Dim elementValue As ElementValue
Dim weights() As Double
Dim value As Series
 
value = FinancialEngine.WeightedMovingAverage(seriesName, s, elementValue, weights)
public static Series WeightedMovingAverage( 
   string seriesName,
   Series s,
   ElementValue elementValue,
   double[] weights
)

Parameters

seriesName
The name of the series which will be displayed on the chart, i.e. its label.
s
An series of historical values, where the first element corresponds to the market on the last period, the second term to the value on previous period and so on.
elementValue
Specifies the particular element value (for example High, Low, Close or Open of the financial time series) which will be considered within this indicator evaluation. In particular, if you wish to use the element value high then you should pass the parameter High. In a similarly fashion if you wish to use the low, close or open, then you should pass the parameter Low, Close, Open, respectively.
weights
Array of doubles which assigns weights to the k-th previous historical values for the given period on which the moving average is being evaluated. Here k is just the length of the weights array given.

Return Value

A series where the first term is the value of the moving average corresponding of the latest period, the second term is the value for the previous period and so on.
Exceptions
ExceptionDescription
Thrown if the length of the weights and series differ or if either array is empty.
Remarks
I.e. The weights shift with the window of the historical values.

Application

Generally speaking the WMA is used in order to allow more weight to be assigned to more resent price dynamics. Here the length of the weights array is used as the length of the period over which the moving average is calculated. If you wish to control the number of periods used within the moving average then we refer you to (historicalPrices, weights, lengthOfMovingAverage).

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also